<template>
  <!-- 第二步:准备容器 -->
  <div ref="charts" class="charts"></div>
</template>

<script>
//第一步:引入echarts插件
import * as echarts from "echarts";
export default {
  name: "",
  mounted() {
    //为什么在这里初始化echarts实例：因为echarts.init方法需要获取容器节点
    //mounted节点挂载完毕，获取到
    let mycharts = echarts.init(this.$refs.charts);
    //配置项
    let option = {
      xAxis: {
        //折线图的拐点分布均分
        type: "category",
      },
      yAxis: {
        //隐藏y轴
        
      },
      //系列
      series: {
        title:{
          show:true,
          text:'销售手机年度报告'
        },
        type: "line",
        data: [10, 90,34,56,78,34, 12, 88, 36, 72, 40, 71],
        //设置平滑曲线
        smooth: true,
        //拐点的样式
        itemStyle: {
          //透明度为零消失
          opacity: 0,
        },
        //线条颜色
        lineStyle: {
          color: "purple",
        },
        //填充颜色
        areaStyle: {
          color: {
            type: "linear",
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [
              {
                offset: 0,
                color: "purple", // 0% 处的颜色
              },
              {
                offset: 1,
                color: "blue", // 100% 处的颜色
              },
            ],
            global: false, // 缺省为 false
          },
        },
      },
      //图形图标的定位
      grid: {
        left: 50,
        top: 100,
        right: 0,
        bottom: 100,
      },
    };
    //设置配置项
    mycharts.setOption(option);
  },
};
</script>

<style scoped>
.charts {
  width: 500px;
  height: 500px;
}
</style>

